import java.util.Comparator;
import java.util.Objects;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2024-01-22
 * Time:13:04
 */
public class Student implements Comparable<Student>,Cloneable{
    private String name;
    private int grade;

    public Student(String name, int grade) {
        this.name = name;
        this.grade = grade;
    }

    public String getName() {
        return name;
    }

    public int getGrade() {
        return grade;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setGrade(int grade) {
        this.grade = grade;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return grade == student.grade;
    }

    @Override
    public int hashCode() {
        return Objects.hash(grade);
    }

    //    @Override
//    public String toString() {
//        return "Student{" +
//                "name='" + name + '\'' +
//                ", grade=" + grade +
//                '}';
//    }

    @Override
    public int compareTo(Student o) {
        return this.grade - o.grade;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
